[main] Bug 648630 Movement Worksheet Creates Incorrect Warehouse Movement for FEFO Lot-Tracked Items - #10924
Conversation
There was a problem hiding this comment.
🟢 Approval recommended
The focused fix matches the root cause and is covered by a representative regression test.
Pull request overview
Corrects FEFO movement worksheet availability by excluding stock already moved to outbound bins.
Changes:
- Subtracts outbound-bin quantities from movement availability, clamped at zero.
- Adds regression coverage for registered and pending picks.
File summaries
| File | Description |
|---|---|
CreatePick.Codeunit.al |
Corrects movement availability calculation. |
SCMMovement.Codeunit.al |
Adds end-to-end regression test and setup helpers. |
Review details
- Files reviewed: 2/2 changed files
- Comments generated: 0
- Review effort level: Balanced
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Good Sense Reviewer - Round 1Recommendation: Request ChangesWhat this PR doesThe change subtracts outbound-bin quantity from directed put-away and pick availability when creating a movement worksheet, and it adds a regression test for FEFO lots with picked-not-shipped and open pick quantities. For replenishing a normal destination bin, this matches the intended rule that a movement must not source stock from outbound bins, and the test covers the reported lot choice. The implementation is still too broad. It subtracts outbound-bin quantity for every movement worksheet call, but the existing movement-worksheet logic keeps ship-zone destinations exempt from that subtraction. Problem-solution fitFit: Partial The reported replenishment scenario is clear, and the change handles the picked-not-shipped lot for a normal destination bin. The fix also changes movements whose destination is the ship zone, which is outside the reported problem and does not match the existing availability rule. SuggestionsS1 (🔴 High): Keep ship-zone movements exempt Risk assessment and necessityRisk: The changed code is in CreatePick.Codeunit.al availability calculation for directed put-away and pick movement worksheets. A wrong availability result can create too little movement or no movement for a valid warehouse movement, especially when the destination is the ship zone. The new test covers the reported FEFO replenishment path, and the required checks are passing. Necessity: The change is needed because movement replenishment should not choose stock that is already picked-not-shipped or committed to another pick. The scope should be narrowed to non-ship destinations so the fix keeps the established ship-zone movement behavior.
|
Good Sense Reviewer - Round 2Recommendation: AcceptWhat this PR doesThis update narrows the outbound-bin subtraction for movement worksheet availability. It now keeps the subtraction for normal replenishment destinations, but leaves ship-zone movements on the existing path. The new guard addresses the previous concern. The reported FEFO replenishment case still excludes picked-not-shipped and pending-pick quantity, while destination movements into the ship zone are no longer shorted by outbound-bin stock. Status of previous suggestions
New observations (commits since round 1)None - the latest change only addresses the previous suggestion. Risk assessment and necessityRisk: The touched code is in directed put-away and pick availability for movement worksheets. A wrong result can pick the wrong lot or create the wrong movement quantity, but the subtraction is now scoped away from ship-zone destinations and the regression test covers the reported FEFO lot case. Necessity: The change is needed because movement replenishment should not choose stock that is already picked-not-shipped or committed to another pick. The scope now matches that need without changing the ship-zone movement rule.
|
Predrag Maricic (PredragMaricic)
left a comment
There was a problem hiding this comment.
The directed put-away-and-pick movement calculation now excludes tracking-filtered quantity already in outbound bins while preserving movements whose destination is a ship zone. The end-to-end FEFO regression test covers registered picked-not-shipped inventory plus a pending pick and verifies selection of the next available lot at the correct quantity. No blocking concerns found.
Bug 648630: [master][ALL-E] Movement Worksheet Creates Incorrect Warehouse Movement for FEFO Lot-Tracked Items When Picked-Not-Shipped and Pending Picks Exist. - regression.
Fixes AB#648630
Issue
Movement Worksheet Creates Incorrect Warehouse Movement for FEFO Lot-Tracked Items When Picked-Not-Shipped and Pending Picks Exist.
Root Cause
The availability calculation in CalcTotalAvailQtyToPick (codeunit 7312 "Create Pick") didn't exclude quantity that was already picked but not yet shipped (sitting in an outbound/ship-type bin) or committed to a pending pick. Since a movement can never source stock from the ship zone, this caused the worksheet to select the wrong (FEFO-earliest) lot for the movement — the lot that was already fully committed to outstanding sales orders — instead of the next available lot.
Solution
In CreatePick.Codeunit.al, when called from the Movement Worksheet (CalledFromMoveWksh), subtract the quantity already sitting on outbound bins (WarehouseAvailabilityMgt.CalcQtyOnOutboundBins) from MaxPickableQtyInWhse before it's added to the total available quantity, clamping at zero.